package com.ctshk.common.enums;

import lombok.Getter;

import java.util.*;

/**
 * 派单管理-公司类型编号
 */
@Getter
public enum CompanyType {

    HK_CT("1001", "香港中旅"),
    HK_NT("1002", "香港国旅"),
    MO_NT("1003", "澳门国旅"),
    ;

    private String code;
    private String name;

    CompanyType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 通过key拿订单状态名称
     * gzl-wansi001
     *
     * @param code
     * @return
     */
    public static String getCompanyTypeName(String code) {
        CompanyType orderPaymentStatus = Arrays.stream(CompanyType.values())
                .filter(enums -> enums.getCode().equals(code)).findFirst().orElse(null);

        if (orderPaymentStatus != null) {
            return orderPaymentStatus.getName();
        }
        return "";
    }

    public static List toList() {
        CompanyType[] values = CompanyType.values();
        List<HashMap<Object, Object>> list = new ArrayList<>();
        for (CompanyType value : values) {
            HashMap<Object, Object> hashMap = new HashMap<>();
            hashMap.put("code", value.getCode());
            hashMap.put("name", value.getName());
            list.add(hashMap);
        }
        return list;
    }
}
